{
                match (left, right) {
                    (BasicValueEnum::IntValue(l), BasicValueEnum::IntValue(r)) => {
                        // Ensure both operands have the same type
                        let (l_casted, r_casted) = if l.get_type() != r.get_type() {
                            // Cast to the wider type
                            if l.get_type().get_bit_width() > r.get_type().get_bit_width() {
                                let r_ext = self.builder.build_int_z_extend_or_bit_cast(
                                    r,
                                    l.get_type(),
                                    "r_cast",
                                )?;
                                (l, r_ext)
                            } else {
                                let l_ext = self.builder.build_int_z_extend_or_bit_cast(
                                    l,
                                    r.get_type(),
                                    "l_cast",
                                )?;
                                (l_ext, r)
                            }
                        } else {
                            (l, r)
                        };
                        let result = self.builder.build_int_compare(
                            inkwell::IntPredicate::SLE,
                            l_casted,
                            r_casted,
                            "lte",
                        )?;
                        // Convert i1 to i32
                        Ok(self
                            .builder
                            .build_int_z_extend(result, self.context.i32_type(), "lte_ext")?
                            .into())
                    }
                    (BasicValueEnum::FloatValue(l), BasicValueEnum::FloatValue(r)) => {
                        // Ensure both operands have the same type
                        let (l_casted, r_casted) = if l.get_type() != r.get_type() {
                            // Cast to the wider type (f64)
                            // f64 has more bits than f32
                            if l.get_type() == self.context.f32_type()
                                && r.get_type() == self.context.f64_type()
                            {
                                let l_ext = self.builder.build_float_ext(
                                    l,
                                    self.context.f64_type(),
                                    "l_cast",
                                )?;
                                (l_ext, r)
                            } else if l.get_type() == self.context.f64_type()
                                && r.get_type() == self.context.f32_type()
                            {
                                let r_ext = self.builder.build_float_ext(
                                    r,
                                    self.context.f64_type(),
                                    "r_cast",
                                )?;
                                (l, r_ext)
                            } else {
                                // Default: cast right to left's type
                                let r_ext =
                                    self.builder.build_float_cast(r, l.get_type(), "r_cast")?;
                                (l, r_ext)
                            }
                        } else {
                            (l, r)
                        };
                        let result = self.builder.build_float_compare(
                            inkwell::FloatPredicate::OLE,
                            l_casted,
                            r_casted,
                            "flte",
                        )?;
                        // Convert i1 to i32
                        Ok(self
                            .builder
                            .build_int_z_extend(result, self.context.i32_type(), "flte_ext")?
                            .into())
                    }
                    _ => Err(CompilerError::internal("Type mismatch in comparison")),
                }
            }
